home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 68 / IOPROG_68.ISO / soft / Tools / AIProSF / AIProSF.exe / ActiveInstall Professional.msi / Data.cab / fMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2003-01-21  |  5.7 KB  |  174 lines

  1. VERSION 5.00
  2. Begin VB.Form fMain 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "WidgetPad"
  5.    ClientHeight    =   6075
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   8490
  9.    BeginProperty Font 
  10.       Name            =   "Tahoma"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   400
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    LinkTopic       =   "Form1"
  19.    MaxButton       =   0   'False
  20.    MinButton       =   0   'False
  21.    ScaleHeight     =   6075
  22.    ScaleWidth      =   8490
  23.    ShowInTaskbar   =   0   'False
  24.    StartUpPosition =   3  'Windows Default
  25.    Begin VB.CommandButton cmdClose 
  26.       Caption         =   "Close"
  27.       Height          =   375
  28.       Left            =   7080
  29.       TabIndex        =   2
  30.       Top             =   540
  31.       Width           =   1335
  32.    End
  33.    Begin VB.CommandButton cmdOpen 
  34.       Caption         =   "Open..."
  35.       Height          =   375
  36.       Left            =   7080
  37.       TabIndex        =   1
  38.       Top             =   120
  39.       Width           =   1335
  40.    End
  41.    Begin VB.TextBox txtMain 
  42.       Height          =   5955
  43.       Left            =   60
  44.       Locked          =   -1  'True
  45.       MultiLine       =   -1  'True
  46.       ScrollBars      =   2  'Vertical
  47.       TabIndex        =   0
  48.       Top             =   60
  49.       Width           =   6915
  50.    End
  51. Attribute VB_Name = "fMain"
  52. Attribute VB_GlobalNameSpace = False
  53. Attribute VB_Creatable = False
  54. Attribute VB_PredeclaredId = True
  55. Attribute VB_Exposed = False
  56. Option Explicit
  57. Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (ofn As OPENFILENAME) As Boolean
  58. Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (ofn As OPENFILENAME) As Boolean
  59. Private Type OPENFILENAME
  60.    lStructSize As Long
  61.    hwndOwner As Long
  62.    hInstance As Long
  63.    stFilter As String
  64.    stCustomFilter As String
  65.    nMaxCustFilter As Long
  66.    nFilterIndex As Long
  67.    strFile As String
  68.    nMaxFile As Long
  69.    stFileTitle As String
  70.    nMaxFileTitle As Long
  71.    stInitialDir As String
  72.    strTitle As String
  73.    flags As Long
  74.    nFileOffset As Integer
  75.    nFileExtension As Integer
  76.    stDefExt As String
  77.    lCustData As Long
  78.    lpfnHook As Long
  79.    lpTemplateName As String
  80. End Type
  81. Public Enum OFN_FLAGS
  82.    OFN_READONLY = &H1
  83.    OFN_OVERWRITEPROMPT = &H2
  84.    OFN_HIDEREADONLY = &H4
  85.    OFN_NOCHANGEDIR = &H8
  86.    OFN_SHOWHELP = &H10
  87.    OFN_ENABLEHOOK = &H20
  88.    OFN_ENABLETEMPLATE = &H40
  89.    OFN_ENABLETEMPLATEHANDLE = &H80
  90.    OFN_NOVALIDATE = &H100
  91.    OFN_ALLOWMULTISELECT = &H200
  92.    OFN_EXTENSIONDIFFERENT = &H400
  93.    OFN_PATHMUSTEXIST = &H800
  94.    OFN_FILEMUSTEXIST = &H1000
  95.    OFN_CREATEPROMPT = &H2000
  96.    OFN_SHAREAWARE = &H4000
  97.    OFN_NOREADONLYRETURN = &H8000
  98.    OFN_NOTESTFILECREATE = &H10000
  99.    OFN_NONETWORKBUTTON = &H20000
  100.    OFN_NOLONGNAMES = &H40000
  101.    OFN_EXPLORER = &H80000
  102.    OFN_NODEREFERENCELINKS = &H100000
  103.    OFN_LONGNAMES = &H200000
  104. End Enum
  105. Private Sub cmdClose_Click()
  106.     Unload Me
  107. End Sub
  108. Private Sub cmdOpen_Click()
  109.     Dim sFile As String
  110.     Dim sFilter As String
  111.     sFilter = "Widget Doc Files (*.wdoc)" & Chr$(0) & "*.WDOC" & Chr$(0) & "All Files (*.*)" & Chr$(0) & "*.*" & Chr$(0)
  112.     sFile = FileOpenSave(OFN_NOCHANGEDIR, CurDir$, sFilter, , ".wdoc", , , hwnd, True)
  113.     If Len(sFile) > 0 Then
  114.         OpenDoc sFile
  115.     End If
  116. End Sub
  117. Private Sub Form_Load()
  118.    On Error GoTo Form_Load_Error
  119.     If Command <> "" Then
  120.         OpenDoc Command
  121.     End If
  122.    On Error GoTo 0
  123.    Exit Sub
  124. Form_Load_Error:
  125.     MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Load of Form fMain"
  126. End Sub
  127. Private Sub OpenDoc(FilePath As String)
  128.     Dim oFS As New Scripting.FileSystemObject
  129.     Dim oTS As TextStream
  130.     FilePath = Replace(FilePath, Chr(34), "")
  131.     Set oTS = oFS.OpenTextFile(FilePath, ForReading)
  132.     txtMain.Text = oTS.ReadAll
  133.     oTS.Close
  134. End Sub
  135. Public Function FileOpenSave(Optional ByRef flags As Long = 0&, Optional ByVal InitialDir As Variant, Optional ByVal Filter As String = vbNullString, Optional ByVal FilterIndex As Long = 1, Optional ByVal DefaultExt As String = vbNullString, Optional ByVal FileName As String = vbNullString, Optional ByVal DialogTitle As String = vbNullString, Optional ByVal hwnd As Long = -1, Optional ByVal OpenFile As Boolean = True) As String
  136.     Dim ofn As OPENFILENAME
  137.     Dim stFileName As String
  138.     Dim stFileTitle As String
  139.     Dim fResult As Boolean
  140.     ' Give the dialog a caption title.
  141.     If IsMissing(InitialDir) Then InitialDir = CurDir
  142.     If (hwnd = -1) Then hwnd = 0
  143.     ' Allocate string space for the returned strings.
  144.     stFileName = Left$(FileName & String$(256, vbNullChar), 256)
  145.     stFileTitle = String$(256, vbNullChar)
  146.     With ofn
  147.         .lStructSize = Len(ofn)
  148.         .hwndOwner = hwnd
  149.         .stFilter = Filter
  150.         .nFilterIndex = FilterIndex
  151.         .strFile = stFileName
  152.         .nMaxFile = Len(stFileName)
  153.         .stFileTitle = stFileTitle
  154.         .nMaxFileTitle = Len(stFileTitle)
  155.         .strTitle = DialogTitle
  156.         .flags = flags
  157.         .stDefExt = DefaultExt
  158.         .stInitialDir = InitialDir
  159.         .hInstance = 0
  160.         .stCustomFilter = String$(255, vbNullChar)
  161.         .nMaxCustFilter = 255
  162.         .lpfnHook = 0
  163.     End With
  164.     If OpenFile Then
  165.         fResult = GetOpenFileName(ofn)
  166.     Else
  167.         fResult = GetSaveFileName(ofn)
  168.     End If
  169.     If fResult Then
  170.         flags = ofn.flags
  171.         FileOpenSave = Left$(ofn.strFile, InStr(1, ofn.strFile, vbNullChar, vbBinaryCompare) - 1)
  172.     End If
  173. End Function
  174.